<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">
<link href="style.css" type="text/css" rel="stylesheet">
<title>HADDPD—Packed Double-FP Horizontal Add </title></head>
<body>
<h1>HADDPD—Packed Double-FP Horizontal Add</h1>
<table>
<tr>
<th>Opcode/Instruction</th>
<th>Op/En</th>
<th>64/32-bit Mode</th>
<th>CPUID Feature Flag</th>
<th>Description</th></tr>
<tr>
<td>
<p>66 0F 7C /<em>r</em></p>
<p>HADDPD <em>xmm1,</em> <em>xmm2/m128</em></p></td>
<td>RM</td>
<td>V/V</td>
<td>SSE3</td>
<td>Horizontal add packed double-precision floating-point values from <em>xmm2/m128</em> to <em>xmm1</em>.</td></tr>
<tr>
<td>
<p>VEX.NDS.128.66.0F.WIG 7C /r</p>
<p>VHADDPD xmm1,xmm2, xmm3/m128</p></td>
<td>RVM</td>
<td>V/V</td>
<td>AVX</td>
<td>Horizontal add packed double-precision floating-point values from xmm2 and xmm3/mem.</td></tr>
<tr>
<td>
<p>VEX.NDS.256.66.0F.WIG 7C /r</p>
<p>VHADDPD ymm1, ymm2, ymm3/m256</p></td>
<td>RVM</td>
<td>V/V</td>
<td>AVX</td>
<td>Horizontal add packed double-precision floating-point values from ymm2 and ymm3/mem.</td></tr></table>
<h3>Instruction Operand Encoding</h3>
<table>
<tr>
<td>Op/En</td>
<td>Operand 1</td>
<td>Operand 2</td>
<td>Operand 3</td>
<td>Operand 4</td></tr>
<tr>
<td>RM</td>
<td>ModRM:reg (r, w)</td>
<td>ModRM:r/m (r)</td>
<td>NA</td>
<td>NA</td></tr>
<tr>
<td>RVM</td>
<td>ModRM:reg (w)</td>
<td>VEX.vvvv (r)</td>
<td>ModRM:r/m (r)</td>
<td>NA</td></tr></table>
<h2>Description</h2>
<p>Adds the double-precision floating-point values in the high and low quadwords of the destination operand and stores the result in the low quadword of the destination operand.</p>
<p>Adds the double-precision floating-point values in the high and low quadwords of the source operand and stores the result in the high quadword of the destination operand.</p>
<p>In 64-bit mode, use of the REX.R prefix permits this instruction to access additional registers (XMM8-XMM15).</p>
<p>See Figure 3-16 for HADDPD; see Figure 3-17 for VHADDPD.</p>
<svg width="507.42" viewBox="132.360000 323587.740000 338.280000 209.220000" height="313.83">
<text y="323605.012572" x="240.031" style="font-size:7.859300pt" lengthAdjust="spacingAndGlyphs" textLength="104.3636447">HADDPD xmm1, xmm2/m128</text>
<text y="323625.163772" x="430.094" style="font-size:7.859300pt" lengthAdjust="spacingAndGlyphs" textLength="21.3930146">xmm2</text>
<text y="323629.879572" x="211.6932" style="font-size:7.859300pt" lengthAdjust="spacingAndGlyphs" textLength="28.4035102">[127:64]</text>
<text y="323629.879572" x="348.691" style="font-size:7.859300pt" lengthAdjust="spacingAndGlyphs" textLength="19.6639686">[63:0]</text>
<text y="323634.594972" x="430.094" style="font-size:7.859300pt" lengthAdjust="spacingAndGlyphs" textLength="21.8409947">/m128</text>
<text y="323677.403772" x="430.094" style="font-size:7.859300pt" lengthAdjust="spacingAndGlyphs" textLength="21.3930146">xmm1</text>
<text y="323677.403972" x="211.6932" style="font-size:7.859300pt" lengthAdjust="spacingAndGlyphs" textLength="28.4035102">[127:64]</text>
<text y="323677.403972" x="348.691" style="font-size:7.859300pt" lengthAdjust="spacingAndGlyphs" textLength="19.6639686">[63:0]</text>
<text y="323730.159572" x="430.0945" style="font-size:7.859300pt" lengthAdjust="spacingAndGlyphs" textLength="24.4581416">Result:</text>
<text y="323730.159772" x="191.0625" style="font-size:7.859300pt" lengthAdjust="spacingAndGlyphs" textLength="69.6726945">xmm2/m128[63:0] +</text>
<text y="323734.875372" x="308.6183" style="font-size:7.859300pt" lengthAdjust="spacingAndGlyphs" textLength="99.81311">xmm1[63:0] + xmm1[127:64]</text>
<text y="323739.590672" x="430.0945" style="font-size:7.859300pt" lengthAdjust="spacingAndGlyphs" textLength="21.3930146">xmm1</text>
<text y="323739.590972" x="190.0801" style="font-size:7.859300pt" lengthAdjust="spacingAndGlyphs" textLength="71.6375195">xmm2/m128[127:64]</text>
<text y="323758.097772" x="211.7034" style="font-size:7.859300pt" lengthAdjust="spacingAndGlyphs" textLength="28.4035102">[127:64]</text>
<text y="323758.097772" x="353.12207234" style="font-size:7.859300pt" lengthAdjust="spacingAndGlyphs" textLength="19.6639686">[63:0]</text>
<text y="323788.4733" x="440.1145" style="font-size:5.894400pt" lengthAdjust="spacingAndGlyphs" textLength="25.8823104">OM15993</text>
<rect y="323588.474" x="133.061" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="181.256" width="331.565"></rect>
<rect y="323588.474" x="133.061" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="181.256" width="331.565"></rect>
<rect y="323613.895" x="292.212" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="26.525" width="132.626"></rect>
<rect y="323613.895" x="159.586" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="26.525" width="132.626"></rect>
<rect y="323718.89" x="159.586" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="26.525" width="132.626"></rect>
<rect y="323718.89" x="292.212" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="26.525" width="132.626"></rect>
<rect y="323613.894" x="159.586" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="26.525" width="132.626"></rect>
<rect y="323661.419" x="159.586" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="26.525" width="132.626"></rect>
<rect y="323718.891" x="159.586" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="26.525" width="132.626"></rect>
<rect y="323718.891" x="292.212" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="26.525" width="132.626"></rect>
<rect y="323613.894" x="292.212" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="26.525" width="132.626"></rect>
<rect y="323661.419" x="292.212" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="26.525" width="132.626"></rect>
<rect y="323661.419" x="159.586" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="26.525" width="132.626"></rect>
<rect y="323661.419" x="292.212" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="26.525" width="132.626"></rect></svg>
<h3>Figure 3-16.  HADDPD—Packed Double-FP Horizontal Add</h3>
<p>X3</p>
<p>X2</p>
<p>X1</p>
<p>X0</p>
<p>SRC1</p>
<p>Y3</p>
<p>Y2</p>
<p>Y1</p>
<p>Y0</p>
<p>SRC2</p>
<p>DEST</p>
<p>Y2 + Y3</p>
<p>X2 + X3</p>
<p>Y0 + Y1</p>
<p>X0 + X1</p>
<h3>Figure 3-17.  VHADDPD operation</h3>
<p>128-bit Legacy SSE version: The second source can be an XMM register or an 128-bit memory location. The desti-nation is not distinct from the first source XMM register and the upper bits (VLMAX-1:128) of the corresponding YMM register destination are unmodified.</p>
<p>VEX.128 encoded version: the first source operand is an XMM register or 128-bit memory location. The destination operand is an XMM register. The upper bits (VLMAX-1:128) of the corresponding YMM register destination are zeroed.</p>
<p>VEX.256 encoded version: The first source operand is a YMM register. The second source operand can be a YMM register or a 256-bit memory location. The destination operand is a YMM register.</p>
<h2>Operation</h2>
<p><strong>HADDPD (128-bit Legacy SSE version)</strong></p>
<pre>DEST[63:0] (cid:197) SRC1[127:64] + SRC1[63:0]
DEST[127:64] (cid:197) SRC2[127:64] + SRC2[63:0]
DEST[VLMAX-1:128] (Unmodified)</pre>
<p><strong>VHADDPD (VEX.128 encoded version)</strong></p>
<pre>DEST[63:0] (cid:197) SRC1[127:64] + SRC1[63:0]
DEST[127:64] (cid:197) SRC2[127:64] + SRC2[63:0]
DEST[VLMAX-1:128] (cid:197) 0</pre>
<p><strong>VHADDPD (VEX.256 encoded version)</strong></p>
<pre>DEST[63:0] (cid:197) SRC1[127:64] + SRC1[63:0]
DEST[127:64] (cid:197) SRC2[127:64] + SRC2[63:0]
DEST[191:128] (cid:197) SRC1[255:192] + SRC1[191:128]
DEST[255:192] (cid:197) SRC2[255:192] + SRC2[191:128]</pre>
<h2>Intel C/C++ Compiler Intrinsic Equivalent</h2>
<p>VHADDPD:</p>
<p>__m256d _mm256_hadd_pd (__m256d a, __m256d b);</p>
<p>HADDPD:</p>
<p>__m128d _mm_hadd_pd (__m128d a, __m128d b);</p>
<h2>Exceptions</h2>
<p>When the source operand is a memory operand, the operand must be aligned on a 16-byte boundary or a general-protection exception (#GP) will be generated.</p>
<h2>Numeric Exceptions</h2>
<p>Overflow, Underflow, Invalid, Precision, Denormal</p>
<h2>Other Exceptions</h2>
<p>See Exceptions Type 2.</p></body></html>